package com.shux.common.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.shux.common.dao.IBaseCommonDao;
@Repository("baseCommonDao")
public abstract class BaseCommonDaoImpl implements IBaseCommonDao {
    @Resource(name = "sqlSessionTemplate")
    private SqlSessionTemplate sqlSessionTemplate;
    @Override
    public int saveObject(String sqlId, Object obj) {
        // TODO Auto-generated method stub
        if(obj == null){
            return sqlSessionTemplate.insert(sqlId);
        }else{
            return sqlSessionTemplate.insert(sqlId, obj);
        }
        
    }

    @Override
    public int updateObject(String sqlId, Object obj) {
        if(null == obj){
            return sqlSessionTemplate.update(sqlId);
        }else{
            return sqlSessionTemplate.update(sqlId, obj);
        }
    }

    @Override
    public Object findForObject(String sqlId, Object obj) {
        if(null == obj){
            return sqlSessionTemplate.selectOne(sqlId);
        }else{
            return sqlSessionTemplate.selectOne(sqlId, obj);
        }
    }

    @Override
    public List<?> findForList(String sqlId, Object obj) {
        if(null == obj){
            return sqlSessionTemplate.selectList(sqlId);
        }else{
            return sqlSessionTemplate.selectList(sqlId, obj);
        }
    }

    @Override
    public int saveBatchObject(String sqlId, List<?> objs) {
        // TODO Auto-generated method stub
        return 0;
    }

}
